package jmine.tec.utils;

import bancosys.tec.exception.LocalizedMessageHolder;
import bancosys.tec.exception.MessageCreator;
import bancosys.tec.exception.MessageCreatorHelper;

/**
 * @author lundberg
 */
public enum UtilsMessages implements MessageCreator {

    INVALID_FILE(1, "utils.invalidFile"),

    URL_NOT_FOUND(0, "utils.urlNotFound"),

    CYCLE_DETECTED(2, "utils.cycleDetected"),

    REFLECTION_ERROR_ACCESSING_SET_METHOD(2, "utils.reflection.errorAccessingSetMethod"),

    EMPTY_SCHEMA(1, "utils.emptySchema"),

    EMPTY_DEPENDENCY(1, "utils.emptyDependency"),

    ERROR_CLEANING_DB(0, "utils.errorCleaningDB"),

    ERROR_FINDING_DAY_OF_THE_WEEK(1, "utils.errorFindingDayOfTheWeek"),

    ERROR_PROCESSING_STATEMENT(3, "utils.errorProcessingStatement"),

    REFLECTION_ILLEGAL_ARGUMENT(3, "utils.reflection.illegalArgument"),

    SQLEXCEPTION(0, "utils.SQLException"),

    ORACLE_UNABLE_TO_QUERY_VIEWS(0, "utils.oracle.unableToQueryViews"),

    EMPTY_TAG(2, "utils.emptyTag"),

    SCRIPT_IOERROR(0, "utils.scriptIOError"),

    COULD_NOT_PROCESS_STATEMENT(1, "utils.couldNotProcessStatement"),

    BASE_PATH_NOT_DEFINED(2, "utils.basePathNotDefined"),

    ERROR_FINDING_FILES(0, "utils.errorFindingFiles"),

    REFERENCE_DATABASE_PARSER_SAXEXCEPTION(1, "utils.referenceDatabaseParser.SAXException"),

    DB_COULD_NOT_DROP(0, "utils.db2.couldNotDrop"),

    CONVERT_PROCESS_FAILED(1, "utils.convertProcessFailed"),

    DEPENDENCY_CYCLE_DETECTED(1, "utils.dependency.cycleDetected"),

    REFLECTION_ERROR_INSTANTIATING(1, "utils.reflection.errorInstantiating"),

    ORACLE_UNABLE_TO_QUERY_TABLES(0, "utils.oracle.unableToQueryTables"),

    REFLECTION_NO_SUCH_METHOD(2, "utils.reflection.noSuchMethod"),

    RESOURCE_NOT_FOUND_ON_CLASSPATH(1, "utils.resourceNotFoundOnClasspath"),

    REFERENCE_DATABASE_PARSER_JDOMEXCEPTION(1, "utils.referenceDatabaseParser.JDOMException"),

    ERROR_CLEANING_LOG_DB(0, "utils.errorCleaningLogDB"),

    REFERENCE_DATABASE_PARSER_IOEXCEPTION(1, "utils.referenceDatabaseParser.IOException"),

    REFLECTION_ILLEGAL_ACCESS_TO_GET_METHOD(2, "utils.reflection.illegalAccessToGetMethod"),

    REFLECTION_ILLEGAL_ACCESS_TO_CONSTRUCTOR(1, "utils.reflection.illegalAccessToConstructor"),

    RESOURCE_NOT_FOUND_CLASSPATH_AND_BASE_PATH(2, "utils.resourceNotFoundClasspathAndBasePath"),

    REFLECTION_ILLEGAL_ARGUMENT_METHOD(2, "utils.reflection.illegalArgumentMethod"),

    REFLECTION_ILLEGAL_ACCESS_TO_SET_METHOD(2, "utils.reflection.illegalAccessToSetMethod"),

    REFLECTION_UNABLE_TO_ACCESS_METHOD(2, "utils.reflection.unableToAccessMethod"),

    DATE_FORMAT(0, "utils.date.format"),

    ORACLE_UNABLE_TO_QUERY_SEQUENCES(0, "utils.oracle.unableToQuerySequences"),

    REFLECTION_ERROR_ACCESSING_METHOD(2, "utils.reflection.errorAccessingMethod"),

    REFLECTION_ERROR_ACCESSING_GET_METHOD(2, "utils.reflection.errorAccessingGetMethod"),

    IOEXCEPTION(0, "utils.IOException"),

    REFLECTION_ILLEGAL_ACCESS_METHOD(2, "utils.reflection.illegalAccessMethod"),

    MALFORMED_URL(0, "utils.malformed.url");

    public static final String DEFAULT_BUNDLE = "jmine-tec-utils-messages";

    private final MessageCreator delegate;

    /**
     * Construtor
     * 
     * @param nargs nargs
     * @param key key
     */
    private UtilsMessages(int nargs, String key) {
        this(DEFAULT_BUNDLE, key, nargs);
    }

    /**
     * Construtor
     * 
     * @param bundle bundle
     * @param key key
     * @param nargs nargs
     */
    private UtilsMessages(String bundle, String key, int nargs) {
        this.delegate = MessageCreatorHelper.creator(bundle, key, nargs);
    }

    /**
     * {@inheritDoc}
     */
    public LocalizedMessageHolder create(Object... arguments) {
        return this.delegate.create(arguments);
    }

    /**
     * {@inheritDoc}
     */
    public int getExpectedArguments() {
        return this.delegate.getExpectedArguments();
    }
}
